/**
 * 
 */
package cn.ivicar.passport.controller.utils;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;

import cn.com.carsmart.ws.model.ValidateCode;
import cn.ivicar.sms.service.SmsService;
/**
 * @Author: liurunbin
 * @Description:短信验证码工具类
 * @Date: Created in 2017/5/22
 */
public class SmsUtil {

	
	private static SmsService smsService = new SmsService();

	/*
	设置短信内容
	 */
	public static void sendSms(ValidateCode code, String content, Integer timeout) {

		content = content == null ? String.format("【全景监控】尊敬的客户，您收到的验证码是：%s，%s分钟内有效,请输入以完成验证，切勿将验证码告知他人。若非本人操作，请忽略此短信。",
				code.getValidateCode(), timeout == null ? 30 : timeout) : content;
		try {
			smsService.sendSms(code.getMobile(), content);
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void sendSms(ValidateCode code) {
		sendSms(code, null, null);
	}

	public static void sendSms(ValidateCode code, String content) {
		sendSms(code, content, null);
	}

	public static void sendSms(ValidateCode code, Integer timeout) {
		sendSms(code, null, timeout);
	}

}
